import 'package:flutter/material.dart';

class HomeNav extends StatelessWidget {
  HomeNav({super.key});

  final List navList = [
    {'text': '我的房屋', 'icon': 'assets/images/house_nav_icon@2x.png'},
    {'text': '在线保修', 'icon': 'assets/images/repair_nav_icon@2x.png'},
    {'text': '访客邀请', 'icon': 'assets/images/visitor_nav_icon@2x.png'},
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.only(top: 20, bottom: 20),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: navList
            .map((item) => GestureDetector(
                  onTap: () {
                    if (item["text"] == '我的房屋') {
                      Navigator.pushNamed(context, '/house');
                    }
                  },
                  child: Column(
                    children: [
                      Image.asset(
                        item['icon'],
                        width: 40,
                        height: 40,
                      ),
                      Text(
                        item['text'],
                        style: const TextStyle(
                          fontSize: 12,
                          color: Color(0xFF434242),
                        ),
                      ),
                    ],
                  ),
                ))
            .toList(),
      ),
    );
  }
}
